package com.first.order.controller;


import com.first.common.pojo.EduCourse;
import com.first.common.vo.Result;
import com.first.order.service.EduCourseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: SecondProject
 * @description:
 * @author: 李榕轩
 * @create: 2023-05-27 16:10
 **/
@RestController
@RequestMapping("order/course")
@Api(tags = "课程接口类")
public class EduCourseController {
    /*
     * queryAllCourse*/
    @Autowired
    private EduCourseService eduCourseService;

    @PostMapping("/queryAllCourse/{courseId}")
    @ApiOperation(value = "条件查询")
    public Result queryAllCourse(@PathVariable String courseId) {
        List<EduCourse> eduCourses = eduCourseService.queryAllCourse(courseId);

        return Result.success(eduCourses);
    }

    @PostMapping("/queryAllCourseAndTeacherName/{id}")
    @ApiOperation(value = "根据课程id查询学生和教师信息")
    public Result queryAllCourseAndTeacherName(@PathVariable String id) {
        //System.out.println(id);
        EduCourse course = eduCourseService.selectCourseAndTeacherName(id);
        //System.out.println(course);
        return Result.success(course);
    }

    @PostMapping("queryAllById/{paramsId}/{mobileId}")
    @ApiOperation(value = "根据手机号查询该视频信息是否该讲师发布的")
    public Result queryAllById(@PathVariable String paramsId, @PathVariable String mobileId) {
        System.out.println(paramsId);
        System.out.println(mobileId);
        Integer integer = eduCourseService.queryAllById(paramsId, mobileId);
        if (integer==0){
            return Result.fail();
        }else {
            return Result.success();
        }


    }
}
